package com.talios.jira.idea.actions;

/*
 * Created by IntelliJ IDEA.
 * User: amrk
 * Date: 13/02/2005
 * Time: 12:18:39
 */

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.project.Project;
import com.talios.jira.idea.JiraConfiguration;
import com.talios.jira.idea.JiraConfigurationComponent;

public abstract class JIRAAction extends AnAction {
    public abstract void actionPerformed(AnActionEvent event);

    public void update(AnActionEvent event) {
        final Project project = (Project) event.getDataContext().getData(DataConstants.PROJECT);
        if (project == null) {
            event.getPresentation().setEnabled(false);
        } else {
            final JiraConfigurationComponent component = project.getComponent(JiraConfigurationComponent.class);
            JiraConfiguration config = component.getConfiguration();
            event.getPresentation().setEnabled(config.getEnableIssueTracking());
        }

    }
}